<template>
  <view class="my-userinfo-container" :style="{height:windowHeight + 'px'}" >
    <!-- 头像昵称区域 -->
    <view class="top-box">
      <image :src="userinfo.avatarUrl" class="info_img"></image>
      <view class="nickname">{{userinfo.nickName}}</view>
    </view>
    <!-- 下侧个人商品信息栏 -->
    <view class="usernum">
      <!-- 收藏浏览区 -->
      <view class="collection" @click="ordersUser">
        <view class="collection_one">
          <text class="num">8</text>
          <text>收藏的店铺</text>
        </view>
        <view class="collection_one">
          <text class="num">12</text>
          <text>收藏的商品</text>
        </view>
        <view class="collection_one">
          <text class="num">10</text>
          <text>关注的商品</text>
        </view>
        <view class="collection_one">
          <text class="num">28</text>
          <text>足迹</text>
        </view>
      </view>
      <!-- 订单区 -->
      <view class="user_ress">
        <view class="orders">我的订单</view>
        <view class="orders_icons" @click="ordersUser">
          <view class="icons_one">
            <image src="../../static/payment.png" class="payment"></image>
            <text>待付款</text>
          </view>
          <view class="icons_one">
            <image src="../../static/receiving.png"></image>
            <text>待收货</text>
          </view>
          <view class="icons_one">
            <image src="../../static/refund.png"></image>
            <text>退款/退货</text>
          </view>
          <view class="icons_one">
            <image src="../../static/orders.png"></image>
            <text>订单</text>
          </view>
        </view>
      </view>
      <!-- 地址区域 -->
      <view class="address_box">
        <view class="address" @click="ordersUser">
          <text>收货地址</text>
          <text> > </text>
        </view>
        <view class="address" @click="ordersUser">
          <text>联系客服</text>
          <text> > </text>
        </view>
        <view class="address" @click="logout">
          <text>退出登录</text>
          <text> > </text>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { mapState,mapMutations } from 'vuex'
  export default {
    name:"my_user",
    props:{
      windowHeight:{
        type:Number,
        default:0
      }
    },
    data() {
      return {
        
      };
    },
    computed:{
     ...mapState('user',['userinfo'])
    },
    methods:{
      ...mapMutations('user',['addAddress','getUserInof','getToken']),
      ordersUser() {
        uni.$showMsg("没钱钱惹！v我50继续开发！")
      },
      async logout() {
        const [err,res] = await uni.showModal({
          title:'提示',
          content:'确定退出登录吗？'
        }).catch(err => err)
        if(res && res.confirm) {
         this.addAddress({})
         this.getUserInof({})
         this.getToken('')
        }
      }
    }
  }
</script>

<style lang="scss">
.my-userinfo-container {
  background-color: #f4f4f4;
  .top-box {
    position: relative;
    height: 400rpx;
    background-color: #FF0000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    .info_img {
      width: 120px;
      height: 120px;
      border-radius: 50%;
    }
    .nickname {
      color: white;
      font-weight: bold;
      font-size: 16px;
      margin-top: 10px;
    }
  }
  .usernum {
    padding: 0 10px;
    position: relative;
    top: -10px;
    .collection {
      background-color: white;
      border-radius: 5px;
      display: flex;
      justify-content: space-between;
      padding: 10px;
      .collection_one {
        display: flex;
        flex-direction: column;
        font-size: 13px;
        .num {
          text-align: center;
        }
      }
    }
    .user_ress {
      margin-top: 8px;
      background-color: white;
      .orders {
        padding: 10px;
        border-bottom: 1px solid #f0f0f0;
        font-size: 18px;
      }
      .orders_icons {
        display: flex;
        justify-content: space-between;
        padding: 10px;
        .icons_one {
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          align-items: center;
          .payment {
            width: 35px;
            height: 35px;
          }
          image {
            width: 40px;
            height: 40px;
          }
        }
      }
    }
    .address_box {
      margin-top: 8px;
      background-color: white;
      .address {
        padding: 10px;
        display: flex;
        justify-content: space-between;
        border-bottom: 1px solid #f0f0f0;
      }
    }
  }
}
</style>